//
//  EvaluateViewController.m
//  AnXin100
//
//  Created by Sakura on 2018/11/1.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "EvaluateViewController.h"
#import "ZXStarAppraiseDisplayView.h"
#import "ZXStarAppraiseView.h"
#import "ZXSampleStarAppraiseView.h"
#import "ChoicePhotoView.h"
@interface EvaluateViewController ()

@property (nonatomic, strong) UIScrollView *mainScroll;

@property (nonatomic, strong) UIView *productView;

@property (nonatomic, strong) UIImageView *productImage;

@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UILabel *priceLabel;

@property (nonatomic, strong) UIButton *shareBtn;

@property (nonatomic, strong) UIView *evaluateView;

@property (nonatomic, strong) ZXStarAppraiseView *starView;

@property (nonatomic, strong) UITextView *textView;

@property (nonatomic, strong) UIView *photoView;

@property (nonatomic, strong) UIView *otherStarView;

@property (nonatomic, strong) ChoicePhotoView *choicePhoto;

@property (nonatomic, strong) UIButton *commitBtn;

@end

@implementation EvaluateViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [PublicMonMethods setupNavigationItems:self];
    [PublicMonMethods settitle:@"评价" viewController:self];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.mainScroll];
    [self.view addSubview:self.commitBtn];
}



#pragma mark - lazy load
- (UIScrollView *)mainScroll {
    if (!_mainScroll) {
        _mainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, Hn, SCREEN_WIDTH, SCREEN_HEIGHT - Hn)];
        _mainScroll.bounces = YES;
        _mainScroll.contentSize = CGSizeMake(0, _mainScroll.mj_h);
        _mainScroll.bounces = YES;
        _mainScroll.alwaysBounceVertical = YES;
        [_mainScroll addSubview:self.productView];
        [_mainScroll addSubview:self.evaluateView];
        
    }
    return _mainScroll;
}


- (UIView *)productView {
    if (!_productView) {
        _productView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 84)];
        [_productView addSubview:self.productImage];
        [_productView addSubview:self.titleLabel];
        [_productView addSubview:self.priceLabel];
    }
    return _productView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        [_productView addSubview:_titleLabel];
        _titleLabel.sd_layout
        .topEqualToView(_productImage)
        .leftSpaceToView(_productView, 84)
        .rightSpaceToView(_productView, 10)
        .heightIs(40);
        _titleLabel.textColor = [UIColor colorWithHex:0x333333];
        _titleLabel.font = [UIFont systemFontOfSize:16];
        _titleLabel.text = @"红心火龙果 4个装 单果约330~420g新鲜水果";
        _titleLabel.numberOfLines = 2;
        [_productView layoutIfNeeded];
    }
    return _titleLabel;
}

- (UIImageView *)productImage {
    if (!_productImage) {
        _productImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 64, 64)];
        _productImage.image = [UIImage imageNamed:@"sg1.jpeg"];
    }
    return _productImage;
}

- (UILabel *)priceLabel {
    if (!_priceLabel) {
        _priceLabel = [UILabel new];
        [_productView addSubview:_priceLabel];
        _priceLabel.sd_layout
        .leftEqualToView(_titleLabel)
        .rightEqualToView(_titleLabel)
        .topSpaceToView(_titleLabel, 9)
        .heightIs(15);
        _priceLabel.textColor = [UIColor colorWithHex:0xFF9E05];
        _priceLabel.font = [UIFont systemFontOfSize:14];
        _priceLabel.text = @"￥44.00";
        [_productView layoutIfNeeded];
    }
    return _priceLabel;
}

- (UIButton *)shareBtn {
    if (!_shareBtn) {
        
    }
    return _shareBtn;
}

- (UIView *)evaluateView {
    if (!_evaluateView) {
        _evaluateView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_productView.frame), SCREEN_WIDTH, _mainScroll.mj_h - CGRectGetMaxY(_productView.frame))];
        UILabel *evaluatelabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, SCREEN_WIDTH, 30)];
        evaluatelabel.text = @"商品评价";
        evaluatelabel.textColor = [UIColor colorWithHex:0x333333];
        evaluatelabel.textAlignment = NSTextAlignmentCenter;
        [_evaluateView addSubview:evaluatelabel];
        
        [_evaluateView addSubview:self.starView];
        [_evaluateView addSubview:self.textView];
        [_evaluateView addSubview:self.choicePhoto];
        [_evaluateView addSubview:self.otherStarView];
    }
    return _evaluateView;
}

- (ZXStarAppraiseView *)starView {
    if (!_starView) {
        _starView = [[ZXStarAppraiseView alloc] initWithFrame:CGRectMake(0, 50, 147.5, 30)];
        _starView.centerX = _evaluateView.centerX;
    }
    return _starView;
}

- (UITextView *)textView {
    if (!_textView) {
        _textView = [[UITextView alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(_starView.frame) + 30, SCREEN_WIDTH - 20, 150)];
        _textView.layer.cornerRadius = 5;
        _textView.layer.borderWidth = 1;
        _textView.layer.borderColor = [UIColor colorWithHex:0xe6e6e6].CGColor;
    }
    return _textView;
}

- (ChoicePhotoView *)choicePhoto {
    if (!_choicePhoto) {
        _choicePhoto = [[ChoicePhotoView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_textView.frame) + 10, SCREEN_WIDTH, SCREEN_WIDTH / 4)];
        _choicePhoto.viewController = self;
        _choicePhoto.takingPictures = YES;
        _choicePhoto.choicePictures = YES;
        _choicePhoto.choiceViedos = NO;
        _choicePhoto.orginalImage = NO;
        _choicePhoto.GIF = NO;
        _choicePhoto.takeBtn = YES;
        _choicePhoto.tailoring = NO;
        _choicePhoto.CircularCut = NO;
        _choicePhoto.multiSelectViedoAndGif = NO;
        _choicePhoto.recordViedo = NO;
        _choicePhoto.showNumber = YES;
        _choicePhoto.maxChoiceImage = 9;
        _choicePhoto.lineImageNumber = 4;
        _choicePhoto.type = Transverse;
    }
    return _choicePhoto;
}

- (UIView *)otherStarView {
    if (!_otherStarView) {
        _otherStarView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_choicePhoto.frame) + 10, SCREEN_WIDTH, 150)];
//        _otherStarView.backgroundColor = [UIColor yellowColor];
        
        NSArray *array = @[@"店铺评价", @"快递评价", @"服务评价"];
        for (NSInteger i = 0; i < array.count; i++) {
            UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10 + 30 * i, 80, 20)];
            titleLabel.text = array[i];
            titleLabel.textColor = [UIColor colorWithHex:0x333333];
            titleLabel.font = [UIFont systemFontOfSize:16];
            
            ZXStarAppraiseView *view = [[ZXStarAppraiseView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(titleLabel.frame) + 10, 10 + 30 * i, 175, 20)];
            [_otherStarView addSubview:titleLabel];
            [_otherStarView addSubview:view];
            
        }
    }
    return _otherStarView;
}

- (UIButton *)commitBtn {
    if (!_commitBtn) {
        _commitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _commitBtn.frame = CGRectMake(0, SCREEN_HEIGHT - 44, SCREEN_WIDTH, 44);
        [_commitBtn setTitle:@"提交" forState:UIControlStateNormal];
        _commitBtn.backgroundColor = COLOR_ORG;
    }
    return _commitBtn;
}

- (void)backAction:(UIBarButtonItem *)item {
    [self.navigationController popViewControllerAnimated:YES];
}


@end
